package com.ruoyi.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.domain.entity.*;
import com.ruoyi.project.domain.query.ProjectDetailLogQuery;
import com.ruoyi.project.domain.query.ProjectPayQuery;
import com.ruoyi.project.mapper.ProjectDetailLogMapper;
import com.ruoyi.project.mapper.ProjectPayMapper;
import com.ruoyi.project.service.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.List;


@Service
public class ProjectDetailLogServiceImpl extends ServiceImpl<ProjectDetailLogMapper, ProjectDetailLog> implements IProjectDetailLogService {

    @Resource
    private ProjectDetailLogMapper projectDetailLogMapper;


    //分页
    @Override
    public TableDataInfo getPage(ProjectDetailLogQuery query) {
        Page<Object> page = PageHelper.startPage(query.getPageNum(), query.getPageSize());
        LambdaQueryWrapper<ProjectDetailLog> queryWrapper = new LambdaQueryWrapper<>();
        List<ProjectDetailLog> list = projectDetailLogMapper.selectList(queryWrapper);
        return new TableDataInfo(list, page.getTotal());
    }

    //新增
    @Override
    public Boolean addInfo(ProjectDetailLog project) {
        return this.save(project);
    }

    @Override
    public Boolean updateInfo(ProjectDetailLog project) {
        return this.updateById(project);
    }

    @Override
    public Boolean deleteInfo(Long id) {
        return this.removeById(id);
    }

    @Override
    public ProjectDetailLog getInfoById(Long id) {
        return this.getById(id);
    }

    @Override
    public List<ProjectDetailLog> getList(ProjectDetailLogQuery query) {
       LambdaQueryWrapper<ProjectDetailLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProjectDetailLog::getDetailId, query.getDetailId());
        queryWrapper.orderByAsc(ProjectDetailLog::getCreateTime);
        return this.list(queryWrapper);
    }


}
